local sk__wenjiu = fk.CreateSkill {

  name = "sk__wenjiu",

  tags = {  },

}

sk__wenjiu:addEffect("active", {
  name = "sk__wenjiu",
  anim_type = "offensive",
  card_num = 0,
  target_num = 0,
  prompt = "#sk__wenjiu",
  derived_piles = "sk__wenjiu",
  can_use = function(self, player)
    return player:usedSkillTimes(sk__wenjiu.name, Player.HistoryPhase) == 0
  end,
  card_filter = Util.FalseFunc,
  on_use = function(self, room, effect)
    local player = effect.from
    local card = room:getNCards(1)
    local color = Fk:getCardById(card[1]).color
    player:addToPile(sk__wenjiu.name, card, true, sk__wenjiu.name, player.id)
    if player.dead or player:prohibitDiscard(Fk:cloneCard("slash")) then return end
    local use=room:askToUseVirtualCard(player,{
      name = "slash",
      prompt = "#sk__wenjiu-use",
      skill_name = sk__wenjiu.name,
      cancelable=false,
      extra_data={
        bypass_times=true,
        bypass_distance=true,
      },
      skip=true,
    })
    if use then
      if color == Card.Black and #player:getPile(sk__wenjiu.name) > 0 then
        use.additionalDamage = (use.additionalDamage or 0) + #player:getPile(sk__wenjiu.name)
        room:moveCardTo(player:getPile(sk__wenjiu.name), Card.DiscardPile, nil, fk.ReasonJustMove, sk__wenjiu.name, nil, true, player)
      end
      room:useCard(use)
      if color == Card.Red and not use.damageDealt and not player.dead and #player:getPile(sk__wenjiu.name) > 0 then
        room:moveCardTo(player:getPile(sk__wenjiu.name), Card.PlayerHand, player, fk.ReasonJustMove, sk__wenjiu.name, nil, true, player)
      end
    end
  end,
})

return sk__wenjiu